import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12

Window {
    visible: true
    width: 1080
    height: 400
    title: qsTr("Transport Cargo control")

    Column{
        id: mainColumn
        anchors.fill: parent
        padding: 5

        Row{
            id: controlRow
            width: parent.width
            height: 100

            spacing: 10

            Button {
                id: startWorkBtn

                width: 150
                height: 50
                anchors.verticalCenter: parent.verticalCenter
                text: dispatcher.isOnDuty ? qsTr("Dispatcher on duty") : qsTr("Dispatcher not on duty")

                onClicked: {
                    dispatcher.isOnDuty = !dispatcher.isOnDuty
                    dispatcher.notifyOnDuty()
                }

                background: Rectangle {
                    id: startWorkBtnBgr
                    color: dispatcher.isOnDuty ? "lightgreen" : "red"
                    radius: 5
                }
            }

            Label{
                id: textLabel
                width: 50
                height: 20
                text: qsTr("cargos:")
            }

            Rectangle {
                id: cargoRec
                height: parent.height - 10
                width: parent.width - startWorkBtn.width - textLabel.width - 50
                border.width: 2
                border.color: "black"

                ListView{
                    id: cargoList
                    anchors.fill: parent

                    orientation: ListView.Horizontal

                    clip: true

                    model: cargoPool.cargoList

                    delegate: Rectangle {
                        width: cargoList.width / 10
                        height: cargoList.height
                        color: "lightblue"
                        border.color: "blue"
                        Text {
                            text: modelData
                            anchors.centerIn: parent
                        }
                    }
                }
                }

        }

        Row{
            id: shipRow
            width: parent.width
            height: 100

            spacing: 10

            Label{
                id: shipListLabel
                width: 50

                height: 20
                text: qsTr("ships:")
            }

            Rectangle {
                height: parent.height - 10
                width: parent.width -100
                border.width: 2
                border.color: "black"

                ListView{
                    id: shipList
                    anchors.fill: parent

                    orientation: ListView.Horizontal

                    clip: true

                    model: shipPool.shipList

                    delegate: Rectangle {
                        width: cargoList.width / 10
                        height: cargoList.height
                        color: "lightyellow"
                        border.color: "blue"
                        Text {
                            text: modelData
                            anchors.centerIn: parent
                        }
                    }
                }
                }

        }

        Row{
            id: resultRow
            width: parent.width
            height: 100

            spacing: 10

            Label{
                id: resultListLabel
                width: 50

                height: 20
                text: qsTr("result:")
            }

            Rectangle {
                height: parent.height - 10
                width: parent.width -100
                border.width: 2
                border.color: "black"

                ListView{
                    id: resultList
                    anchors.fill: parent

                    orientation: ListView.Horizontal

                    clip: true

                    model: shipPool.loadedShipList

                    delegate: Rectangle {
                        width: resultList.width / 10
                        height: resultList.height
                        color: "lightyellow"
                        border.color: "blue"
                        Text {
                            text: modelData
                            anchors.centerIn: parent
                        }
                    }
                }
                }

        }

    }

}
